import { Cache } from "../../cache/Cache";
import { GameDefConfig } from "../../resource/GameDefConfig";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { EVIPType } from "../../../../Message/Public/EVIPType";
import { VIPConfig } from "../../resource/VIPConfig";
type int = number;
//class VIPUtil
    
    export  class VIPUtil
    {
        

        public static toVipHookMap(): void
        {
            var loc4=null;
            var loc5=null;
            var loc6=0;
            var loc7=false;
            var loc8=0;
            var loc1=Cache.instance.role.entityInfo.level;
            var loc2=1;
            var loc3=GameDefConfig.instance.getVipHookMapData();
            if (loc3) 
            {
                (loc4 = loc3.concat()).sortOn("text", Array.NUMERIC | Array.CASEINSENSITIVE);
                loc6 = loc4.length;
                loc7 = false;
                loc8 = 0;
                while (loc8 < loc6) 
                {
                    loc5 = loc4[loc8];
                    if (loc1 < Number(loc5.text)) 
                    {
                        loc7 = true;
                        if (loc8 > 0) 
                        {
                            loc5 = loc4[(loc8 - 1)];
                            loc2 = int(loc5.text1);
                        }
                        break;
                    }
                    ++loc8;
                }
                if (!loc7) 
                {
                    loc5 = loc4[(loc6 - 1)];
                    loc2 = int(loc5.text1);
                }
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.EnterVIPHook, loc2));
            return;
        }

        public static getVipPetRefreshRate(arg1: EVIPType): int
        {
            return VIPUtil.getVIPAttributeName(arg1, "EVIPCodePetRefreshRate");
        }

        public static getVipPetStrengthRate(arg1: EVIPType): int
        {
            return VIPUtil.getVIPAttributeName(arg1, "EVIPCodePetStrengthRate");
        }

        /* internal  */static getAttributeName(arg1: EVIPType): string
        {
            var loc1="";
            var loc2=arg1.value();
            switch (loc2) 
            {
                case EVIPType._EVIPTypeHalfYear:
                {
                    loc1 = "halfYearVal";
                    break;
                }
                case EVIPType._EVIPTypeMonth:
                {
                    loc1 = "monthVal";
                    break;
                }
                case EVIPType._EVIPTypeWeek:
                {
                    loc1 = "weekVal";
                    break;
                }
            }
            return loc1;
        }

        /* internal  */static getVIPAttributeName(arg1: EVIPType, arg2: string): int
        {
            var loc1=VIPUtil.getAttributeName(arg1);
            if (loc1 == "") 
            {
                return 0;
            }
            return VIPConfig.instance.getVIPInfo(arg2)[loc1];
        }
    }
